//
//  WYFJsBridge.h
//  NetEaseFinancial
//
//  Created by 吴玉峰 on 8/18/15.
//  Copyright (c) 2015 吴玉峰. All rights reserved.
//

#import <Foundation/Foundation.h>

static const int EXECUTE_NATIVE_FUNCTION = 1;
static const int EXECUTE_JAVASCRIPT_CALLBACK = 2;
static const int EXECUTE_JAVASCRIPT_FUNCTION = 3;
static const int EXECUTE_NATIVE_CALLBACK = 4;
static const int EXECUTE_NATIVE_FUNCTION_SYNC = 5;

@class WYFJSCommand;
@class WYFWebViewProxyDelegate;

typedef void (^ObjectiveCFunction)(WYFJSCommand *cmd);
typedef void (^JavascriptCallback)(WYFJSCommand *cmd);

@interface WYFJSBridge : NSObject

+ (NSString *)createSerial;

- (instancetype)initWithWebViewProxyDelegate:(WYFWebViewProxyDelegate *)webViewProxyDelegate;

- (void)execute:(NSString *)cmdName params:(NSDictionary *)params jsCallback:(id)jsCallback;

- (void)executeObjectiveCFunction:(WYFJSCommand *)cmd;

- (void)registerCommandWithName:(NSString *)name objectiveCFunction:(id)objectiveCFunction;

- (BOOL)handleCommand:(WYFJSCommand *)cmd;

@end
